package com.photologics.main;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import com.photologics.logic.LogicHelper;
import com.photologics.logic.LogicHelper.coinGiveType;
import com.photologics.logic.LogicHelper.item;
import com.photologics.logic.SelectSectionActivity;

public class GiveCoinDialog extends Dialog {
	private Context con;
	private TextView amount;
	private ImageView giveImage;

	public GiveCoinDialog(Context context, coinGiveType type) {
		super(context);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.give_coin_dialog);
		
		amount = (TextView) findViewById(R.id.amount_coin);
		amount.setText(Integer.toString(type.value()));
		giveImage = (ImageView) findViewById(R.id.give_image);
		giveImage.setImageResource(R.drawable.item_coin);

		LogicHelper.accountInfo.changeCoin(type.value());

		final Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			@Override
			public void run() {
				dismiss();
			}
		}, 1500);
	}

	public GiveCoinDialog(Context context, item item, int count) {
		super(context);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.give_coin_dialog);

		con =context;
		
		amount = (TextView) findViewById(R.id.amount_coin);
		amount.setText(Integer.toString(count));

		giveImage = (ImageView) findViewById(R.id.give_image);
		switch (item) {
		case SHOW:
			giveImage.setImageResource(R.drawable.item_showimage);
			LogicHelper.accountInfo.changeShowImage(count);
			break;
		case REMOVE:
			giveImage.setImageResource(R.drawable.item_removex);
			LogicHelper.accountInfo.changeRemoveX(count);
			break;
		case NONE:
			giveImage.setImageResource(R.drawable.item_coin);
			LogicHelper.accountInfo.changeCoin(count);
			break;
		}

		// amountOfCoin.setTextSize(bd.getBitmap().getHeight());
		// defalutText.setTextSize(bd.getBitmap().getHeight());

		final Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			@Override
			public void run() {
				Intent intent = new Intent(con, SelectSectionActivity.class);
				con.startActivity(intent);
				dismiss();
			}
		}, 1500);

	}
}
